
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--    <meta charset=utf-8">-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>数据库后台</title>
    <!-- BOOTSTRAP STYLES-->
<!--    <link href="../css/bootstrap.css" rel="stylesheet" />-->
    <link href="../css/bootstrap.min.css" rel="stylesheet" />
    <!-- CUSTOM STYLES-->
    <link href="../css/custom.css" rel="stylesheet" />
    <!-- /. WRAPPER  -->
    <!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
    <!-- JQUERY SCRIPTS -->
    <script src="../js/jquery-1.7.1.min.js"></script>
    <!-- BOOTSTRAP SCRIPTS -->
    <script src="../js/bootstrap.min.js"></script>
    <!-- METISMENU SCRIPTS -->
    <script src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"charset="UTF-8"></script>
    <script src="../js/common.js"></script>
</head>

<body>
<div id="wrapper">
    <nav class="navbar navbar-default navbar-cls-top " role="navigation"
         style="margin-bottom: 0">
        <div class="navbar-header">
            <!--                 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse"> -->
            <!--                     <span class="sr-only">Toggle navigation</span> -->
            <!--                     <span class="icon-bar"></span> -->
            <!--                     <span class="icon-bar"></span> -->
            <!--                     <span class="icon-bar"></span> -->
            <!--                 </button> -->
            <a class="navbar-brand">任务分配</a>
        </div>
        <div
                style="color: white; padding: 15px 50px 5px 50px; float: right; font-size: 16px;">
            <!--            <form action="../loginOut.jsp" method="post">-->
            <button id = "loginout" class="btn btn-danger">注销</button>
            <!--            </form>-->

        </div>
    </nav>
    <!-- /. NAV TOP  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">
<!--                <li class="text-center"><img src="<%=img%>"-->
<!--                                             class="user-image img-responsive" /></li>-->


                <!-- 					<li><a href="../index.jsp"><i -->
                <!-- 							class="fa fa-dashboard fa-3x"></i> 主页</a></li> -->
                <!-- 					<li><a href="UserInfo.jsp"><i class="fa fa-table fa-3x"></i> -->
                <!-- 							个人信息</a></li> -->
<!--                <li><a href="TeacherSelfExam.jsp"><i-->
<!--                        class="fa fa-desktop fa-3x"></i> 竞赛批改</a></li>-->
                <li><a href="formsubmit.html"><i class="fa fa-qrcode fa-3x"></i>
                                    表单录入</a></li>
                <li><a href="distribute.html"><i
                        class="fa fa-bar-chart-o fa-3x"></i> 任务分配</a></li>
                <li><a href="feedback.html"><i
                        class="fa fa-bar-chart-o fa-3x"></i> 数据反馈</a></li>
                <li><a href="usermanage.html"><i
                        class="fa fa-bar-chart-o fa-3x"></i> 用户管理</a></li>
                <li><a href="searchlist.html"><i
                        class="fa fa-bar-chart-o fa-3x"></i> 数据查询</a></li>


                <!-- 					<li><a href="ChangePassword.jsp"><i -->
                <!-- 							class="fa fa-edit fa-3x"></i> 密码修改 </a></li> -->

            </ul>

        </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper">
        <div id="page-inner">

            <div class="container">
                <fieldset>
                    <legend>任务分配</legend>
                    <p>未分配资源
                    <input id="ResourcesNumber"  disabled="disabled"/>

                    </p>
                    <p>
                        <input type="button" id="searchlist" class="btn btn-primary" value="查找" />
                        <input type="button" id="confirm" class="btn btn-primary" value="确认分配" />
                    </p>

                    <div class="row" style="padding: 50px 20px 0px 20px">

                        <div class="table-responsive">
                            <table class="table table-striped" id="table1"
                                   style="text-align: center">
     `                           <thead>
                                <td>用户名</td>
                                <td>真实姓名</td>
                                <td>今日已分配资源</td>
                                <td>选择是否分配</td>
                                </thead>
                                <tbody>

                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="col-sm-offset-5 col-sm-7">
                        <input id="ebutton" type="button" value="导出EXCEL"
                               onClick="getXlsFromJsp('table1')" class="btn btn-primary"
                               style="display: none">
                    </div>
                </fieldset>
            </div>
            <!-- /. PAGE INNER  -->
        </div>
        <!-- /. PAGE WRAPPER  -->
    </div>
<!--    <script type="text/javascript" src="../js/AjaxAPI.js" charset="UTF-8"></script>-->
<!--    <script src="../js/jquery.dataTables.js"></script>-->
</div>
    <script type="text/javascript">
        $(document).ready(function () {

            $("#searchlist").click(function () {
                let d1 = {
                    temp: "temp",
                };
                $.ajax({
                    type: "POST",
                        url: "../login/searchUser3list",
                        contentType: "application/json;charset=utf-8",
                        data: JSON.stringify(d1),
                        dataType: "json",
                        success: function (data) {
                        if (data == null) {
                            // window.location.href = "/msgtable/html/login.html"
                            alert("无权限")
                        } else {
                            $('table tbody').html('');
                            $.each(data, function (i, item) {
                                // alert(item.userName)
                                // var _len = $("#tab tr").length;
                                var rowmsg = "<tr id= align='center'>"
                        + "<td>" + item.userName + "</td>"
                        + "<td>" + item.realName + "</td>"
                        + "<td>" + item.dailyNum + "</td>"
                        + "<td><input type='checkbox' name='vegetable' value="+item.id+"/></td>";
                            rowmsg = rowmsg + "</tr>";
                        $("#table1").append(rowmsg);

                    })
                }
            },
                    error: function (data) {
                        window.location.href = "/msgtable/html/login.html"
                        alert("请登录")
                    }
                });
            });
            $("#confirm").click(function () {
                var vegetable = "";
                $("input:checkbox[name='vegetable']:checked").each(function(){//根据name属性，寻找到元素，对应的checked状态
                    vegetable += $(this).val() + "";
                });
               if (vegetable==""){
                    alert("请选择")
               }else{
                   let d1 = {
                       userName: vegetable,
                   };
                   $.ajax({
                       type: "POST",
                       url: "../distribute/part",
                       contentType: "application/json;charset=utf-8",
                       data:JSON.stringify(d1),
                       dataType: "text",
                       success:function (data) {
                           // window.location.href= "/msgtable/html/formsubmit.html"
                           // alert("提交成功"+JSON.stringify(message));
                           alert(data)
                           $("#searchlist").click();
                       },
                       error:function (data) {
                           alert(data)
                       }
                   });
               }


            })

        })
    </script>


<script type="text/javascript">

    $.ajax({
        type: "POST",
        url: "../distribute/ResourcesNumber",
        dataType: "text",
        success:function (data) {
                $("#ResourcesNumber").val(data);
        },
        error:function (data) {
            window.location.href= "/msgtable/html/login.html";
            alert("请登录")
        }
    });




</script>





</body>
</html>